<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\massage\model;

class CouponService extends \app\BaseModel
{
    protected $name = "massage_service_coupon_goods";
    public function dataAdd($data)
    {
        $res = $this->insert($data);
        return $res;
    }
    public function goodsUpdate($dis, $data)
    {
        $spe = $data["spe"];
        unset($data["spe"]);
        $res = $this->where($dis)->update($data);
        $this->updateSome($dis["id"], $data["uniacid"], $spe);
        return $res;
    }
    public function updateSome($id, $uniacid, $coach)
    {
        $spe_model = new GoodsSpe();
        $spe_model->where(["goods_id" => $id])->delete();
        if(!empty($spe)) {
            foreach ($spe as $value) {
                $value["uniacid"] = $uniacid;
                $value["goods_id"] = $id;
                $spe_model->dataAdd($value);
            }
        }
        return true;
    }
    public function dataUpdate($dis, $data)
    {
        $res = $this->where($dis)->update($data);
        return $res;
    }
    public function dataList($dis, $page)
    {
        $data = $this->where($dis)->order("top desc,id desc")->paginate($page)->toArray();
        return $data;
    }
    public function dataInfo($dis)
    {
        $data = $this->where($dis)->find();
        return !empty($data) ? $data->toArray() : [];
    }
}

?>